/*
	QUBE
	Sandra Obermann - QPT 1 - 2012
	fhs33730 - 1110601021
	FH Salzburg - Studiengang MultiMediaTechnolgy
*/

// Own written Includes
#include "../include/QubeTimer.h"

// Initialize QubeTimer with: Session Time, Delta Time and Game Time beginning with 0
QubeTimer::QubeTimer()
{
	resetSessionTime();
	m_delta = 0;
	m_lastTime = ci::app::getElapsedSeconds();
}

// Default Destructor for QubeTimer element
QubeTimer::~QubeTimer()
{
	
}

// Update all QubeTimer Times
void QubeTimer::updateTime( double passedTime )
{
	// delta is the time difference between two frames
	// lastTime is elapsed time since start from the last frame
	// passedTime is elapsed time since start from this frame
	m_delta = fabs( m_lastTime - passedTime );
	m_lastTime = passedTime;

	// when game is running increment current session time
	if( m_sessionActive )
	{
		m_sessionTime += m_delta;
	}
}

// Returns the Delta Time
double QubeTimer::getDeltaTime()
{
	return m_delta;
}

// Returns current Game Time
double QubeTimer::getSessionTime()
{
	return m_sessionTime;
}

// Resets current Game Time
void QubeTimer::resetSessionTime()
{
	m_sessionTime = 0;
	m_sessionActive = true;
}

// Stops the current Session Time ( needed for the Time Score at the finish screen )
void QubeTimer::stopSessionTime()
{
	m_sessionActive = false;
}